<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.17"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>AWTK-CPP: TListView类 参考</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">AWTK-CPP
   </div>
   <div id="projectbrief">AWTK CPP API</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.8.17 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'搜索');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','搜索');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public 成员函数</a> &#124;
<a href="#pub-static-methods">静态 Public 成员函数</a> &#124;
<a href="class_t_list_view-members.html">所有成员列表</a>  </div>
  <div class="headertitle">
<div class="title">TListView类 参考</div>  </div>
</div><!--header-->
<div class="contents">

<p><code>#include &lt;<a class="el" href="awtk__cpp_8hpp_source.html">awtk_cpp.hpp</a>&gt;</code></p>
<div class="dynheader">
类 TListView 继承关系图:</div>
<div class="dyncontent">
 <div class="center">
  <img src="class_t_list_view.png" alt=""/>
 </div></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public 成员函数</h2></td></tr>
<tr class="memitem:a982414111db4eda0b7f57b55655c22b7"><td class="memItemLeft" align="right" valign="top"><a id="a982414111db4eda0b7f57b55655c22b7"></a>
&#160;</td><td class="memItemRight" valign="bottom"><b>TListView</b> (widget_t *nativeObj)</td></tr>
<tr class="separator:a982414111db4eda0b7f57b55655c22b7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0101a4e978e9c4cad97d8e768a4398d7"><td class="memItemLeft" align="right" valign="top"><a id="a0101a4e978e9c4cad97d8e768a4398d7"></a>
&#160;</td><td class="memItemRight" valign="bottom"><b>TListView</b> (const list_view_t *nativeObj)</td></tr>
<tr class="separator:a0101a4e978e9c4cad97d8e768a4398d7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adf1dbc60fcfea1d99317098f223e044f"><td class="memItemLeft" align="right" valign="top">ret_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_t_list_view.html#adf1dbc60fcfea1d99317098f223e044f">SetItemHeight</a> (int32_t item_height)</td></tr>
<tr class="separator:adf1dbc60fcfea1d99317098f223e044f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8aefe762a75dc97429561f01862dcea1"><td class="memItemLeft" align="right" valign="top">ret_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_t_list_view.html#a8aefe762a75dc97429561f01862dcea1">SetDefaultItemHeight</a> (int32_t default_item_height)</td></tr>
<tr class="separator:a8aefe762a75dc97429561f01862dcea1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab0cea8ab7a332d997ff930c400e0ff8d"><td class="memItemLeft" align="right" valign="top">ret_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_t_list_view.html#ab0cea8ab7a332d997ff930c400e0ff8d">SetAutoHideScrollBar</a> (bool auto_hide_scroll_bar)</td></tr>
<tr class="separator:ab0cea8ab7a332d997ff930c400e0ff8d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a76d89b0c447847b9413fdcadb7f150f8"><td class="memItemLeft" align="right" valign="top">ret_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_t_list_view.html#a76d89b0c447847b9413fdcadb7f150f8">Reinit</a> ()</td></tr>
<tr class="separator:a76d89b0c447847b9413fdcadb7f150f8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad61f7e14732c4748c4536f3cd8b8200f"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_t_list_view.html#ad61f7e14732c4748c4536f3cd8b8200f">GetItemHeight</a> () const</td></tr>
<tr class="separator:ad61f7e14732c4748c4536f3cd8b8200f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2d797a372cce32c7dfdd40aecb029524"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_t_list_view.html#a2d797a372cce32c7dfdd40aecb029524">GetDefaultItemHeight</a> () const</td></tr>
<tr class="separator:a2d797a372cce32c7dfdd40aecb029524"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afad912c2620024379dbd3a7f66049dcd"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_t_list_view.html#afad912c2620024379dbd3a7f66049dcd">GetAutoHideScrollBar</a> () const</td></tr>
<tr class="separator:afad912c2620024379dbd3a7f66049dcd"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-methods"></a>
静态 Public 成员函数</h2></td></tr>
<tr class="memitem:ab52b9d5571139ca33f7631c294434695"><td class="memItemLeft" align="right" valign="top"><a id="ab52b9d5571139ca33f7631c294434695"></a>
static <a class="el" href="class_t_list_view.html">TListView</a>&#160;</td><td class="memItemRight" valign="bottom"><b>Cast</b> (widget_t *nativeObj)</td></tr>
<tr class="separator:ab52b9d5571139ca33f7631c294434695"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad1ab04f22e07af89f23faaa3aaae07c3"><td class="memItemLeft" align="right" valign="top"><a id="ad1ab04f22e07af89f23faaa3aaae07c3"></a>
static <a class="el" href="class_t_list_view.html">TListView</a>&#160;</td><td class="memItemRight" valign="bottom"><b>Cast</b> (const widget_t *nativeObj)</td></tr>
<tr class="separator:ad1ab04f22e07af89f23faaa3aaae07c3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a18e3bccf0d56caedf32accbcad2b940c"><td class="memItemLeft" align="right" valign="top"><a id="a18e3bccf0d56caedf32accbcad2b940c"></a>
static <a class="el" href="class_t_list_view.html">TListView</a>&#160;</td><td class="memItemRight" valign="bottom"><b>Cast</b> (TWidget &amp;obj)</td></tr>
<tr class="separator:a18e3bccf0d56caedf32accbcad2b940c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a557e18b0b9358c6e8457c101a6606cf8"><td class="memItemLeft" align="right" valign="top"><a id="a557e18b0b9358c6e8457c101a6606cf8"></a>
static <a class="el" href="class_t_list_view.html">TListView</a>&#160;</td><td class="memItemRight" valign="bottom"><b>Cast</b> (const TWidget &amp;obj)</td></tr>
<tr class="separator:a557e18b0b9358c6e8457c101a6606cf8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4caf5f5ba77fd7bc70fda422739b3e4d"><td class="memItemLeft" align="right" valign="top">static TWidget&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_t_list_view.html#a4caf5f5ba77fd7bc70fda422739b3e4d">Create</a> (TWidget &amp;parent, xy_t x, xy_t y, wh_t w, wh_t h)</td></tr>
<tr class="separator:a4caf5f5ba77fd7bc70fda422739b3e4d"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">详细描述</h2>
<div class="textblock"><p>列表视图控件。</p>
<p>列表视图控件是一个可以垂直滚动的列表控件。</p>
<p>如果不需要滚动，可以用view控件配置适当的layout参数作为列表控件。</p>
<p>列表视图中的列表项可以固定高度，也可以使用不同高度。请参考<a href="https://github.com/zlgopen/awtk/blob/master/demos/assets/default/raw/ui/list_view_vh.xml">变高列表项</a></p>
<p>列表视图控件的中可以有滚动条，也可以没有滚动条。 可以使用移动设备风格的滚动条，也可以使用桌面风格的滚动条。</p>
<p>list_view_t是widget\_t的子类控件，widget_t的函数均适用于list_view_t控件。</p>
<p>在xml中使用"list\_view"标签创建列表视图控件。如：</p>
<div class="fragment"><div class="line">*&lt;<span class="keywordtype">list_view</span> <span class="keyword">x</span>=<span class="stringliteral">&quot;0&quot;</span>  <span class="keyword">y</span>=<span class="stringliteral">&quot;30&quot;</span> <span class="keyword">w</span>=<span class="stringliteral">&quot;100%&quot;</span> <span class="keyword">h</span>=<span class="stringliteral">&quot;-80&quot;</span> <span class="keyword">item_height</span>=<span class="stringliteral">&quot;60&quot;</span>&gt;</div>
<div class="line">*&lt;<span class="keywordtype">scroll_view</span> <span class="keyword">name</span>=<span class="stringliteral">&quot;view&quot;</span> <span class="keyword">x</span>=<span class="stringliteral">&quot;0&quot;</span>  <span class="keyword">y</span>=<span class="stringliteral">&quot;0&quot;</span> <span class="keyword">w</span>=<span class="stringliteral">&quot;100%&quot;</span> <span class="keyword">h</span>=<span class="stringliteral">&quot;100%&quot;</span>&gt;</div>
<div class="line">*&lt;<span class="keywordtype">list_item</span> <span class="keyword">style</span>=<span class="stringliteral">&quot;odd&quot;</span> <span class="keyword">children_layout</span>=<span class="stringliteral">&quot;default(rows=1,cols=0)&quot;</span>&gt;</div>
<div class="line">*&lt;<span class="keywordtype">image</span> <span class="keyword">draw_type</span>=<span class="stringliteral">&quot;icon&quot;</span> <span class="keyword">w</span>=<span class="stringliteral">&quot;30&quot;</span> <span class="keyword">image</span>=<span class="stringliteral">&quot;earth&quot;</span>/&gt;</div>
<div class="line">*&lt;<span class="keywordtype">label</span> <span class="keyword">w</span>=<span class="stringliteral">&quot;-30&quot;</span> <span class="keyword">text</span>=<span class="stringliteral">&quot;1.Hello AWTK !&quot;</span>&gt;</div>
<div class="line">*&lt;<span class="keywordtype">switch</span> <span class="keyword">x</span>=<span class="stringliteral">&quot;r:10&quot;</span> <span class="keyword">y</span>=<span class="stringliteral">&quot;m&quot;</span> <span class="keyword">w</span>=<span class="stringliteral">&quot;60&quot;</span> <span class="keyword">h</span>=<span class="stringliteral">&quot;20&quot;</span>/&gt;</div>
<div class="line">*&lt;/<span class="keywordtype">label</span>&gt;</div>
<div class="line">*&lt;/<span class="keywordtype">list_item</span>&gt;</div>
<div class="line">*...</div>
<div class="line">*&lt;/<span class="keywordtype">scroll_view</span>&gt;</div>
<div class="line">*&lt;/<span class="keywordtype">list_view</span>&gt;</div>
</div><!-- fragment --><blockquote class="doxtable">
<p>注意：列表项不是作为列表视图控件的直接子控件，而是作为滚动视图的子控件。 </p>
</blockquote>
<blockquote class="doxtable">
<p>更多用法请参考：[list_view_m.xml]( </p>
</blockquote>
<p><a href="https://github.com/zlgopen/awtk/blob/master/demos/assets/default/raw/ui/list_view_m.xml">https://github.com/zlgopen/awtk/blob/master/demos/assets/default/raw/ui/list_view_m.xml</a>)</p>
<p>在c代码中使用函数list_view_create创建列表视图控件。如：</p>
<p>用代码构造列表视图是比较繁琐的事情，最好用XML来构造。 如果需要动态修改，可以使用widget_clone来增加列表项，使用widget_remove_child来移出列表项。</p>
<p>可用通过style来设置控件的显示风格，如背景颜色和边框颜色等(一般情况不需要)。 </p>
</div><h2 class="groupheader">成员函数说明</h2>
<a id="a4caf5f5ba77fd7bc70fda422739b3e4d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4caf5f5ba77fd7bc70fda422739b3e4d">&#9670;&nbsp;</a></span>Create()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">TWidget TListView::Create </td>
          <td>(</td>
          <td class="paramtype">TWidget &amp;&#160;</td>
          <td class="paramname"><em>parent</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">xy_t&#160;</td>
          <td class="paramname"><em>x</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">xy_t&#160;</td>
          <td class="paramname"><em>y</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">wh_t&#160;</td>
          <td class="paramname"><em>w</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">wh_t&#160;</td>
          <td class="paramname"><em>h</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>创建list_view对象</p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">parent</td><td>父控件 </td></tr>
    <tr><td class="paramname">x</td><td>x坐标 </td></tr>
    <tr><td class="paramname">y</td><td>y坐标 </td></tr>
    <tr><td class="paramname">w</td><td>宽度 </td></tr>
    <tr><td class="paramname">h</td><td>高度</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>对象。 </dd></dl>

</div>
</div>
<a id="afad912c2620024379dbd3a7f66049dcd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#afad912c2620024379dbd3a7f66049dcd">&#9670;&nbsp;</a></span>GetAutoHideScrollBar()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool TListView::GetAutoHideScrollBar </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>如果不需要滚动条时，自动隐藏滚动条。 </p>

</div>
</div>
<a id="a2d797a372cce32c7dfdd40aecb029524"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2d797a372cce32c7dfdd40aecb029524">&#9670;&nbsp;</a></span>GetDefaultItemHeight()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t TListView::GetDefaultItemHeight </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>列表项的缺省高度。如果item_height &lt;= 0 而且列表项自身的高度 &lt;= 0，则使用缺省高度。 </p>

</div>
</div>
<a id="ad61f7e14732c4748c4536f3cd8b8200f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad61f7e14732c4748c4536f3cd8b8200f">&#9670;&nbsp;</a></span>GetItemHeight()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int32_t TListView::GetItemHeight </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>列表项的高度。如果 item_height 0，所有列表项使用固定高度，否则使用列表项自身的高度。 </p>

</div>
</div>
<a id="a76d89b0c447847b9413fdcadb7f150f8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a76d89b0c447847b9413fdcadb7f150f8">&#9670;&nbsp;</a></span>Reinit()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">ret_t TListView::Reinit </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>list_view重新初始化。</p>
<dl class="section return"><dt>返回</dt><dd>返回RET_OK表示成功，否则表示失败。 </dd></dl>

</div>
</div>
<a id="ab0cea8ab7a332d997ff930c400e0ff8d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab0cea8ab7a332d997ff930c400e0ff8d">&#9670;&nbsp;</a></span>SetAutoHideScrollBar()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">ret_t TListView::SetAutoHideScrollBar </td>
          <td>(</td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>auto_hide_scroll_bar</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>设置是否自动隐藏滚动条。</p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">auto_hide_scroll_bar</td><td>是否自动隐藏滚动条。</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>返回RET_OK表示成功，否则表示失败。 </dd></dl>

</div>
</div>
<a id="a8aefe762a75dc97429561f01862dcea1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8aefe762a75dc97429561f01862dcea1">&#9670;&nbsp;</a></span>SetDefaultItemHeight()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">ret_t TListView::SetDefaultItemHeight </td>
          <td>(</td>
          <td class="paramtype">int32_t&#160;</td>
          <td class="paramname"><em>default_item_height</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>设置列表项的缺省高度。</p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">default_item_height</td><td>列表项的高度。</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>返回RET_OK表示成功，否则表示失败。 </dd></dl>

</div>
</div>
<a id="adf1dbc60fcfea1d99317098f223e044f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#adf1dbc60fcfea1d99317098f223e044f">&#9670;&nbsp;</a></span>SetItemHeight()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">ret_t TListView::SetItemHeight </td>
          <td>(</td>
          <td class="paramtype">int32_t&#160;</td>
          <td class="paramname"><em>item_height</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>设置列表项的高度。</p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">item_height</td><td>列表项的高度。</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>返回RET_OK表示成功，否则表示失败。 </dd></dl>

</div>
</div>
<hr/>该类的文档由以下文件生成:<ul>
<li>output/<a class="el" href="awtk__cpp_8hpp_source.html">awtk_cpp.hpp</a></li>
<li>output/awtk_cpp.cpp</li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者 &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.17
</small></address>
</body>
</html>
